<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 <!doctype html>
<html lang="zh">
<head>
<title>会员中心</title>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
	<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/matrix-style.css" />
<link rel="stylesheet" href="css/matrix-media.css" />
<link rel="stylesheet" href="jquery-easyui/themes/default/easyui.css" />
<link rel="stylesheet" href="jquery-easyui/themes/icon.css" />
<script type="text/javascript" src="jquery-easyui/jquery.min.js"></script>
<script type="text/javascript" src="jquery-easyui/jquery.easyui.min.js"></script>
 <script charset="utf-8" src="editor/kindeditor-all.js"></script>
<script charset="utf-8" src="editor/lang/zh-CN.js"></script>
<link rel="stylesheet" href="editor/themes/default/default.css"></link>
<script type="text/javascript" src="editor/plugins/code/prettify.js"></script> 
	<link rel="stylesheet" href="nitification/css/Lobibox.min.css"/>
    <link rel="stylesheet" href="nitification/css/animate.css"/>
	  <script src="js/bootstrap.min.js"></script>
    <script src="nitification/js/notifications.js"></script>
   <!--[if IE]>
		<script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script>
	<![endif]-->
<style>
 .content-header{
/*   margin-top:-38px;
 */  font-size:16px;
  background-color:#fff;
 }
 .content-header table{
  font-weight:bolder;
  margin-left:30px;
 }
 .content-header .header-number{
  margin-left:10px;
 }
 .widget-box .widget-content  td{
  text-align:center;
 }
 /*easyui*/
#fm {
	margin: 0;
	padding: 10px 30px;
}

.ftitle {
	font-size: 14px;
	font-weight: bold;
	padding: 5px 0;
	margin-bottom: 10px;
	border-bottom: 1px solid #ccc;
}

.fitem {
	margin-bottom: 5px;
}

.fitem label {
	display: inline-block;
	width: 80px;
}

.fitem input {
	width: 160px;
} 

#userinfo{
  list-style:none;
  
}
#userinfo li{
 float:left;
 display:inline-block;
 width:25%;
}
</style> 
<script>
function logout(){
		$.messager.confirm('Confirm','Are you sure you want to logout?',function(r){
            if (r){
                $.post('<%=request.getContextPath()%>/logout',function(result) {
					if (result.success) {
						$.messager.show({ // show error message
							title : '提示',
							msg : '退出成功'
						});
			           }
				 else {
						$.messager.show({ // show error message
									title : '提示',
									msg : '登录已过期，重新登录'
								});
					   }
				}, 'json');
    			window.open('<%=request.getContextPath()%>/index.jsp','_self');

		     }
	});
}
function profile(){
	window.open('<%=request.getContextPath()%>/profile?method=page','_self');
}
function gohome(){
	window.open('<%=request.getContextPath()%>/dashboard','_self');
}
</script>
<script type="text/javascript">
$(document).ready(function(){
	setInterval(function(){
		$.ajax({
			url:"<%=request.getContextPath()%>/member?method=timermessage",
			dataType:'json',
			type:"post",
			data:{},
			beforeSend:function(){
				
			},
			success:function(result){
				if(result.success){
					$.each(result.messages,function(i,item){
						alertNotification(item.content);
					})
				}
			}
		})
		
	},1000*60);
	
	
	$.ajax({
		url:"<%=request.getContextPath()%>/task?method=taskcount",
		dataType:'json',
		type:'post',
		data:{},
		beforeSend:function(){
			
		},
		success:function(result){
			if(result.success){
				$("#count").text(result.count);
			}
		}
	})
	$('#dg').datagrid({
		    title:'会员总列表',
	        width:'100%',
		    pagination:true,
		    rownumbers:true,
		    fitColumns:true,
		    singleSelect:false,
		    idField:'uid',
		    url:'<%=request.getContextPath()%>/member?method=total',
		    columns:[[
   		        {field:'ck',checkbox:true},
		        {field:'uid',title:'编号',width:"25%",
	              styler:function(value,row,index){
/* 			        		return ' cursor:pointer';
*/			        },
		    		formatter:function(value,row,index){
		       			return '<a href="#" title="点击可查看会员详情" onclick="readUser('+index+')">'+value+'</a>';
		    			
		    		}
    		    },
		        {field:'name',title:'姓名',width:'10%' 
		        },
		        {field:'school',title:'学校',width:'20%'},
		        {field:'grade',title:'年级',width:"10%",
			     formatter:function(value,row,index){
			    	switch (row.grade) {
					case 1:
						return '大一';
						break;
					case 2:
						return '大二';
						break;
					case 3:
						return '大三';
						break;
					case 4:
						return '大四';
						break;

					default:
						return '(空)';
						break;
					}
			     }
		        },
		        {field:'type',title:'会员类型',width:'10%',
					formatter:function(value,row,index){
						switch(row.type){
						case 1:
							return '普通会员';
							break;
						case 2:
							return 'vip会员';
							break;
						default:
								break;
						}
						
					}
		         },
		        {field:'due',title:'到期时间',width:'20%',
		         formatter:function(value,row,index){
		        	 if(row.type=='1'){
		        		 return '(无)';
		        	 }else{
		        		 return row.due;
		        	 }
		         }	 
		         },
		        {field:'phone',title:'手机号',hidden:true},
		        {field:'email',title:'邮箱',hidden:true},
		        {field:'openid',title:'openid',hidden:true},
		        {field:'assistid',title:'助理',hidden:true}
		    ]],
			 onClickRow: function (index, row) {//点击事件
					
		     } ,
		     onLoadSuccess:function(index,row){
		    	 var s= $("#dg").datagrid('getPanel');
		    	 var rows = s.find('tr.datagrid-row');
		    	 var rows1 = s.find('tr.datagrid-row td[field!=ck]');
		    	 rows1.unbind('click').bind('click',function(e){
		    	     return false; 
		      });  
		     }
		});
	//header menu
var ddlMenu1 = $('#li1').menubutton({ menu: '#cusmenu1' }); 
var ddlMenu2 = $('#li2').menubutton({ menu: '#cusmenu2' }); 

//menubutton 依赖于 menu、linkbutton 这两个插件，所以我们可以这样搞定她
$(ddlMenu1.menubutton('options').menu).menu({
            onClick: function (item) {
            	if(item.id=='id1'){
            		
            	}else if(item.id=='id2'){
                    window.open("<%=request.getContextPath()%>/task?method=assisttasks","_blank")

            	}else if(item.id=='id3'){
                    window.open("<%=request.getContextPath()%>/","_self")
            	}
            }
	})
	$(ddlMenu2.menubutton('options').menu).menu({
	            onClick: function (item) {
	            	 if(item.id=='id4'){
	            	}
	            }
	})
	
	
	
	
	
});
</script>

<script>
function vip(){
	$("#dg").datagrid({
		url:"<%=request.getContextPath()%>/member?method=vip"
	})
}
function ordinary(){
	$("#dg").datagrid({
		url:"<%=request.getContextPath()%>/member?method=ordinary"
				
	
	})

}
function total(){
	$("#dg").datagrid({
		url:"<%=request.getContextPath()%>/member?method=total",
		onSubmit:function(){
			
		},
		success:function(){
			
		}
	})

}

function addUser(){
	$("#fm1").form('clear');
	$('#dlg1').dialog('open').dialog('setTitle','添加会员');
	
}

/* window.onload=function(){
	$("#type0").combobox({
		 onChange:function(){
			 if($("#type0").combobox('getValue')=='1'){
				 $("#due0").combobox('readonly',true);
			 }
			if($("#type0").combobox('getValue')=='2'){
				$("#due0").combobox('readonly',false);
			}
		 }
	 }) ;
} */
function doAdd(){

 $("#fm1").form('submit',{
	 url:"<%=request.getContextPath()%>/member?method=adduser",
	 onSubmit:function(){
		if(!$(this).form('validate')){
			return false;
		}
	 },
	 success:function(result){
		 var result=eval('('+result+')');
		 if(result.success){
			 $.messager.show({
				 title:'提示',
				 msg:'添加成功'
				 
			 })
			 $("#dlg1").dialog('close');
			 $("#dg").datagrid("reload");
		 }
		 
	 }
	 
 })
 
}
function newBackup(){
	var rows = $('#dg').datagrid('getSelections');
	if(rows.length==1){
		  $('#dlg').dialog('open').dialog('setTitle','添加备注');
		    $("#fm").form("load",rows[0]);
		  url='<%=request.getContextPath()%>/member?method=backadd&uid='+rows[0].uid;
	}else if(rows.length>1){
		 $.messager.show({
             title: 'Error',
             msg: "不能同时选中多个会员进行备份，一次选中一个"
         });
	}
}

function backdelete(id){
	$.messager.confirm('Confirm','Are you sure you want to delete?',function(r){
        if (r){
            $.post('<%=request.getContextPath()%>/member?method=backdelete&id='+id,function(result) {
				if (result.success) {
					$.messager.show({ // show error message
						title : '提示',
						msg : '删除成功'
					});
					$("#dg2").datagrid('reload');
		           }
			 else {
					$.messager.show({ // show error message
							title : '提示',
							msg : '删除失败'
						});
				   }
			}, 'json');

	     }
});
}
function backedit(index){
	$("#dg2").datagrid('selectRow', index);
	var row=$("#dg2").datagrid("getSelected");
	$("#dlg3").dialog('open').dialog('setTitle','修改备注');
	$("#fm3").form('load',row); 
	url="<%=request.getContextPath()%>/member?method=backedit&id="+row.id;
}
function doupdate(){
	$("#fm3").form("submit",{
		url:url,
		onSubmit:function(){
			
		},
		success:function(result){
            var result = eval('('+result+')');
			if(result.success){
				$.messager.show({
					title:'success',
					msg:'修改备注成功'
				})
				$("#dlg3").dialog('close')
				$("#dg2").datagrid('reload');
			}else{
				$.messager.show({
					title:'Error',
					msg:'编辑失败'
				})
			}
			
		}
	})
}
function showBackup(){
	var rows = $('#dg').datagrid('getSelections');
	if(rows.length==1){
		  $('#dlg2').dialog('open').dialog('setTitle','查看编辑备注');
		  $('#dg2').datagrid({
			    width:'100%',
			    pagination:true,
			    rownumbers:true,
			    fitColumns:true,
			    singleSelect:true,
			    idField:'id',
			    url:'<%=request.getContextPath()%>/member?method=backlist&uid='+rows[0].uid,
			    columns:[[
			        {field:'id',title:'编号'},
			        {field:'content',title:'内容' },
			        {field:'datetime',title:'日期时间'},
			        {field:'do',title:'操作',width:70,align:'center',
			            formatter:function(value,row,index){
			                if (true){
			                    var q = '<a href="#" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="backedit('+index+')">编辑</a>  ';
			                    var z = '<a href="#" class="easyui-linkbutton"  onclick="backdelete('+row.id+')">删除</a>  ';
			                    return q+z;
			                } else {
			                    var e = '<a href="#" onclick="editrow('+index+')">Edit</a> ';
			                    var d = '<a href="#" onclick="deleterow('+index+')">Delete</a>';
			                    return e+d;
			                }
			            }
			        }
			    ]],
			});
	}else if(rows.length>1){
		 $.messager.show({
             title: 'Error',
             msg: "一次只能选中一个"
         });
	}
}
function readUser(index){
	  var rows=$("#dg").datagrid("getRows");
		$('#dlg4').dialog('open').dialog('setTitle','会员资料');
		$("#uid").text(rows[index].uid);
		$('#name').text(rows[index].name);
		$("#type").text(function(){
			switch (rows[index].type) {
			case 1:
				return '普通会员';
				break;
			case 2:
				return 'vip会员'
				break;
			default:
				break;
			}
		});
		$("#phone").text(rows[index].phone);
		$("#email").text(rows[index].email);
		$('#school').text(rows[index].school);
		$("#grade").text(function(){
			switch (rows[index].grade) {
			case 1:
				return '大一';
				break;
			case 2:
				return '大二';
				break;
			case 3:
				return '大三';
				break;
			case 4:
				return '大四';
				break;
			default:
				break;
			}
		});
		$("#due").text(rows[index].due);
		$("#assistid").text(rows[index].assistid); 
		$("#file-btn").click(function(){
			 $.ajax({
					url:'<%=request.getContextPath()%>/member?method=files',
					dataType:'json',
					type:'post',
					data:{uid:$("#uid").text()},
					beforeSend:function(){
						
					},
					success:function(result){
						if(result.filelist!=null){
							var str='';
							$.each(result.filelist,function(i,item){
								str+='<tr><td><a href="'+item[2]+'" >'+item[3]+'</a></td><td><a href="#" onclick="deleteFile(this,\''+item[1]+'\'\,\''+item[2]+'\')">delete</a></td></tr>';
							})
							$("#file-tab").html(str);
						}
					}
				}) 
				$("#dlg7").dialog('open').dialog('setTitle','上传客户文件');
		});
		$("#task-btn").click(function(){
			$.ajax({
				url:'<%=request.getContextPath()%>/member?method=tasks',
				type:'post',
				dataType:'json',
				data:{uid:$("#uid").text()},
				beforeSend:function(){
					
				},
				success:function(result){
					if(result.tasklist!=null){
						var str='';
						$.each(result.tasklist,function(i,item){
							str+='<tr><td><a href="#" onclick="taskInfo('+item.id+')">'+item.name+'</a></td><td><a href="#" onclick="deleteTask(this,'+item.id+')">取消关联</a></td></tr>';
						})
						$("#task-tab").html(str);
					}
				}
			})
			$("#dlg8").dialog('open').dialog('setTitle','相关任务');
		})
		
		$("#edit-btn").unbind('click').bind('click',function(){
				$("#dlg12").dialog('open').dialog('setTitle','编辑会员资料');
				$('#due2').datebox({
				    formatter: function(date){ 
				    	return date.getFullYear()+'-'+(date.getMonth()+1)+'-'+date.getDate();
				     },
				    parser: function(date){
				    	return new Date(Date.parse(date.replace(/-/g,"/")));
			    }
				});
/*  				 $("#fm12").form('load',rows[index]); 
 */                 $("#uid2").textbox('setValue',$("#uid").text());
                 $("#name2").textbox('setValue',$("#name").text());
                 if($("#type").text()=='普通会员'){
                	 $("#leixing").combobox('setText','普通会员');
                	 $("#leixing").combobox('setValue',1);
                 }else{
                	 $("#leixing").combobox('setText','vip会员');
                	 $("#leixing").combobox('setValue',2);
                 }
				 $("#phone2").textbox('setValue',$('#phone').text());
				 $("#email2").textbox('setValue',$('#email').text());
				 $("#school2").textbox('setValue',$('#school').text());
				 if($("#grade").text()=='大一'){
					 $("#grade2").combobox('setValue','1');
					 $("#grade2").combobox('setText',$("#grade").text());
					 
				 }else if($("#grade").text()=='大二'){
					 $("#grade2").combobox('setValue','2');
					 $("#grade2").combobox('setText',$("#grade").text());
				 }else if($("#grade").text()=='大三'){
					 $("#grade2").combobox('setValue','3');
					 $("#grade2").combobox('setText',$("#grade").text());
				 }else if($("#grade").text()=='大四'){
					 $("#grade2").combobox('setValue','4');
					 $("#grade2").combobox('setText',$("#grade").text());
				 }
        		 $("#due2").datebox('setValue',$("#due").text());
				 $("#assistid2").textbox('setValue',$('#assistid').text()); 
			 	 if($("#leixing").combobox('getValue')=='2'){
					 $("#fm12 .easyui-datebox").datebox('readonly',false);
				 }
			 	 if($("#leixing").combobox('getValue')=='1'){
					 $("#fm12 .easyui-datebox").datebox('readonly',true);
			 	 }
		});
		 $("#leixing").combobox({
			 onChange:function(){
				 if($("#fm12 input[name='type']").val()=='1'){
						$("#fm12 .easyui-datebox").datebox('readonly','readyonly');
					} 
					 if($("#fm12 input[name='type']").val()=='2'){
						 $("#fm12 .easyui-datebox").datebox('readonly',false);
					 }
			 }
		 }) 
		 $("#addcomment").click(function(){
			 $.ajax({
				 url:'<%=request.getContextPath()%>/member?method=addcomment',
				 type:'post',
				 dataType:'json',
				 data:{content:$("#commentid").val(),uid:$("#uid").text()},
				 beforeSend:function(){
					 if($("#commentid").val()==""){
						 $.messager.show({
							 title:'提示',
							 msg:'不能为空'
						 })
						 return false;
					 }
					 
				 },
				 success:function(result){
					 if(result.timermessage!=null){
						 $.messager.show({
							 title:'提示',
							 msg:'添加成功'
						 })
						var str='<div><div style="width:100px;height:100px;float:left;">'+result.timermessage.assistid+'</div>'+
					    '<p>'+result.timermessage.content+'</p>'+
					    '<div><a href="#" style="padding:0px 10px;" class="easyui-linkbutton" onclick="deletecomment(this\,'+result.timermessage.id+')">删除</a>'+
					    '<a href="#" style="padding:0px 10px;" class="easyui-linkbutton" onclick="editcomment(this\,'+result.timermessage.id+')">修改</a>'+
					    '<a href="#" style="padding:0px 10px;" class="easyui-linkbutton" onclick="showTimer('+result.timermessage.id+')" >设置提醒</a>'+
					    '<a href="#" style="padding:0px 10px;" class="easyui-linkbutton" onclick="deleteTimer(this)" >取消提醒</a></div>'+
					    '</div><div style="clear:both;"></div></div>';
						 $("#commentlist").prepend(str);
						 
					 }else{
						 $("#commentlist").prepend('');
					 }
				 }
			 })
		 });
		 
		 //加载所有评论
		 $.ajax({
				url:'<%=request.getContextPath()%>/member?method=commentlist',
			    type:'post',
			    dataType:'json',
			    data:{uid:$("#uid").text()},
			    beforeSend:function(){
			    	
			    },
			    success:function(result){
			    	var str="";
			    	if(result.comments){
			    		 $.each(result.comments,function(i,item){
					    		str+='<div><div style="width:100px;height:100px;float:left;">'+item.assistid+'</div>'+
								    '<p>'+item.content+'</p>'+
								    '<div><a href="#" style="padding:0px 10px;" class="easyui-linkbutton" onclick="deletecomment(this\,'+item.id+')">删除</a>'+
								    '<a href="#" style="padding:0px 10px;" class="easyui-linkbutton" onclick="editcomment(this\,'+item.id+')">修改</a>'+
								    '<a href="#" style="padding:0px 10px;" class="easyui-linkbutton" onclick="showTimer('+item.id+')" >设置提醒</a>'+
								    '<a href="#" style="padding:0px 10px;" class="easyui-linkbutton" onclick="deleteTimer(this)" >取消提醒</a></div>'+
								    '</div><div style="clear:both;"></div></div>';
					    	})
					    	$("#commentlist").html(str);
			    	}else{
				    	$("#commentlist").html('');
			    	}
			    }
			})

}

function deleteFile(ele,uid,url){
	$.messager.confirm('Confirm',"确定删除？",function(r){
		if(r){
			$.post('<%=request.getContextPath()%>/member?method=deletefile',{uid:uid,url:url},function(result){
				if(result.success){
					$.messager.show({
						title:'提示',
						msg:'删除成功'
					})
					$(ele).parent().parent().remove();
				}
				
			},'json');
		}
	})
	
}

KindEditor.ready(function(K) {
	var editor = K.editor({
		resizeType: 1,
		fullscreenMode: 0, //是否全屏显示
		designMode: 1,
		uploadJson:'editor/jsp/upload_json.jsp',
	    fileManagerJson : 'editor/jsp/file_manager_json.jsp',
		allowPreviewEmoticons: false,
		allowImageUpload: true,
		allowFileManager: true
	});
	K('#insertfile').click(function() {
		editor.loadPlugin('insertfile', function() {
			editor.plugin.fileDialog({
				clickFn : function(url, title) {
					$.ajax({
						url:'<%=request.getContextPath()%>/member?method=addfile',
						dataType:'json',
						type:'post',
						data:{uid:$("#uid").text(),url:url,title:title},
						beforeSend:function(){
						},
						success:function(result){
							var str='<tr><td><a href="'+url+'">'+title+'</a></td><td><a href="#" onclick="deleteFile(this,\''+$("#uid").text()+'\'\,\''+url+'\')">delete</td></tr>';
							$("#file-tab").prepend(str);
						}
					});
					editor.hideDialog();
				}
			});
		});
	});
}); 
function taskInfo(id){
	$.ajax({
		url:'<%=request.getContextPath()%>/task?method=taskinfo',
		dataType:'json',
		type:'json',
		data:{id:id},
		beforeSend:function(){
			
		},
		success:function(){
			
		}
	})
}
function deleteTask(ele,id){
	$.messager.confirm('Confirm',"确定取消关联？",function(r){
		if(r){
			$.post('<%=request.getContextPath()%>/task?method=deleteuser',{taskid:id,uid:$("#uid").text()},function(result){
				if(result.success){
					$.messager.show({
						title:'提示',
						msg:'删除成功'
					})
					$(ele).parent().parent().remove();
				}
				
			},'json');
		}
	})
}

function userLink(){
	 $.ajax({
		 url:'<%=request.getContextPath()%>/member?method=linkvalue',
		 type:'post',
		 dataType:'json',
		 data:{uid:$("#uid").text()},
		 beforeSend:function(){
			 
		 },
		 success:function(result){
				if(result.success){
					$('#link-id').text(result.url);
				}else{
					$('#link-id').text('');
				}
		 }
	 })
	$("#dlg9").dialog('open').dialog('setTitle','链接');
	
	 $("#user-link").change(function(){
		 $.ajax({
			 url:'<%=request.getContextPath()%>/member?method=userlink',
			 type:'post',
			 dataType:'json',
			 data:{uid:$("#uid").text(),url:$(this).val()},
			 beforeSend:function(){
				
				 
			 },
			 success:function(result){
				 $.messager.show({
					 title:'提示',
					 msg:'成功'
				 })
			 }
		 })
		$('#link-id').text($(this).val());

			
		})
	$("#link-id").click(function(){
		var url='';
		if($(this).text().indexOf('http://')>-1){
			url=$(this).text();
		}else{
			url='http://'+$(this).text();
		}
		window.open(url,"_blank");
	})
}
/* function gotoLink(ele){
	var url='';
	if($(this).text().indexOf('http://')>-1){
		url=$(this).text();
	}else{
		url='http://'+$(this).text();
		alert(url);
	}
	window.open(url,'_blank');
} */
function userTravels(){
	$.ajax({
		url:'<%=request.getContextPath()%>/member?method=usertravels',
		dataType:'json',
		type:'post',
		data:{uid:$("#uid").text()},
		beforeSend:function(){
			
		},
		success:function(result){
			if(result.success){
				if(result.travellist!=null){
					var str='';
					$.each(result.travellist,function(i,item){
						str+='<tr><td><a href="#" onclick="travelInfo('+item.id+')">'+item.title+'</a></td><td></td></tr>';
					})
					$("#travel-tab").html(str);
				}else{
					$("#travel-tab").html("");

				}
			}
		}
	});
	$("#dlg10").dialog('open').dialog('setTitle','相关活动');
	
}

function travelInfo(id){
	$("#dlg11").dialog('open').dialog('setTitle','活动详情');
	$.ajax({
		url:'<%=request.getContextPath()%>/member?method=travelinfo',
		dataType:'json',
		type:'post',
		data:{travelid:id},
		beforeSend:function(){
			
		},
		success:function(result){
			if(result.success){
				$("#tit").text(result.travel.title);
				$("#span1").text(result.travel.datetime);
				$("#span2").text(result.travel.money);
				$("#travel").html(result.travel.content);
			}else{
				$("#tit").text('');
				$("#span1").text('');
				$("#span2").text("");
				$("#travel").html("");
			}
		}
	})
}

function doedit(){
	$("#fm12").form('submit',{
		url:'<%=request.getContextPath()%>/member?method=useredit',
		onSubmit:function(){
			
		},
		success:function(result){
			var result=eval('('+result+')');
			if(result.success){
				$.messager.show({
					title:'提示',
					msg:'修改成功'
				})
				$("#dlg12").dialog('close');
				$("#name").text($("#fm12 input[name='name']").val());
				$("#type").text(function(){
					switch($("#fm12 input[name='type']").val()){
					case '1':
						return '普通会员';
						break;
					case '2':
						return 'vip会员';
						break;
					default:
						break;
						
					}
				});
				//修改成后，同步面板数据
				$("#phone").text($("#fm12 input[name='phone']").val());
				$("#email").text($("#fm12 input[name='email']").val());
				$("#school").text($("#fm12 input[name='school']").val());
				$("#grade").text($("#fm12 input[name='grade']").val());
                $("#due").text($("#fm12 input[name='due']").val());
				$("#assistid").text($("#fm12 input[name='assistid']").val());
				$("#dg").datagrid('reload');

			}
			
		}
	})
}

function myUsers(){
	var url="<%=request.getContextPath()%>/member?method=myuser";
	$('#dg').datagrid('reload',url);
	
}
function sendEmail(){
	var rows=$("#dg").datagrid('getSelections');
	if(rows.length>0){
		var item=[];
		for(var i=0;i<rows.length;i++){
			item.push(rows[i].email);
		}
		$('#to').textbox('setValue', item.toString());
		$("#dlg5").dialog('open').dialog('setTitle','邮件发送');
		 KindEditor.create("#editor_id",{
			 cssPath:'editor/plugins/code/prettify.css',
	 		 resize:0,
			 uploadJson:'editor/jsp/upload_json.jsp',
		     fileManagerJson : 'editor/jsp/file_manager_json.jsp',
			 allowPreviewEmoticons:true,
			 allowImageUpload:true,			
			 width:'100%',
			 afterBlur:function() {
			      this.sync();
			  }
			 }) ;
			url="<%=request.getContextPath()%>/member?method=email";
	}
}
function send(){
	$("#fm5").form('submit',{
		url:url,
		onSubmit:function(){
			
		},
		success:function(result){
            var result = eval('('+result+')');
			if(result.success){
				$.messager.show({
					title:'success',
					msg:'邮件发送成功'
				})
				$("#dlg5").dialog('close')
			}else{
				$.messager.show({
					title:'Error',
					msg:'邮件发送失败'
				})
			}
		}
	})
}
function gotoMytask(){
	window.open('<%=request.getContextPath()%>/task','_self');
}
</script> 
<script>
function deletecomment(ele,id){
	$.ajax({
		url:'<%=request.getContextPath()%>/member?method=deletecomment',
		dataType:'json',
		type:'post',
		data:{id:id},
		beforeSend:function(){
			
		},
		success:function(result){
			if(result.success){
				$.messager.show({
					title:'提示',
					msg:'删除成功'
					
				})
				$(ele).parent().parent().remove();
			}
		}
	})
}
function editcomment(ele,id){
	$.messager.prompt('Prompt', 'Please enter the new major type:', function(r){
		if (r){
			 $.ajax({
					url:"<%=request.getContextPath()%>/member?method=editcomment",
					dataType:'json',
					type:'post',
					data:{id:id,content:r},
					beforeSend:function(){
						if(r==""){
							return false;
						}
					
					},
					success:function(result){
						if(result.success){
							$.messager.show({
								title:'提示',
								msg:'编辑成功'
								
							})
							$(ele).parent().parent().children("p").text(r);
						}
						
					}
				})
		}
	});
	
	}

function showTimer(id){
	$("#dlg13").dialog('open').dialog('setTitle','设置时间');
	url='<%=request.getContextPath()%>/member?method=settimer&id='+id;
	
}
function setTimer(){//设置消息提醒
	$.ajax({
		url:url,
		type:'post',
		dataType:'json',
		data:{datetime:$("#timer").datetimebox('getValue')},
		beforeSend:function(){
			if($("#timer").datetimebox('getValue')==""){
				return false;
			}
		},
		success:function(result){
			if(result.success){
				$("#dlg13").dialog('close');
				$.messager.show({
					title:"提示",
					msg:"设置消息提醒成功"
					
				})
				
			}
			
			
		}
	})
	
}



 function alertNotification(msg){
	   Lobibox.notify('info', {
           delay: false,
           icon:false,
           title: '新消息提醒',
           msg: msg,
           closeOnClick:true
           
       });
 }
window.onload=function(){
/* 		setInterval(alertNotification,10000);
 */}
 </script>
</head>
 <body>
<!--Header-part-->
<div id="header">
  <h1><a href="dashboard.html">Matrix Admin</a></h1>
</div>
<!--close-Header-part--> 

<!-- header menu -->
<ul style="position:absolute;left:200px;top:20px;list-style:none;">
 <li id="li2" style="float:left;padding:5px;color:#0094ff;font-size:12px;" icon="icon-lightning" onclick="gohome()">首页</li>
</ul>

<!-- header menu -->
<!-- header menu -->
<div id="welcome" >
<h3 style="position:absolute;top:5px;right:30px;font-size:16px;height:35px;line-height:32px;background:white;border-radius:10px 10px">
<a href="#" onclick='gotoMytask()'><span style="padding:5px;border-radius:10px 10px ;color:white;background:red;" id="count"></span></a>

<a href="#" class="easyui-menubutton" data-options="menu:'#mm5',iconCls:'icon-man'" style="color:#0094ff;">${sessionScope.assist.id }</a>
</h3>
</div>
<div id="mm5" style="width:150px;">
		<div data-options="iconCls:'icon-undo'" onclick="profile()">个人设置</div>
		<div class="menu-sep"></div>
		<div>我的任务</div>
		<div class="menu-sep"></div>
		<div>系统消息</div>
		<div class="menu-sep"></div>
		<div onclick="logout()">安全退出</div>
</div>
<!-- side bar start -->
<div id="sidebar" >
  <ul>
    <li  ><a  href="<%=request.getContextPath()%>/dashboard"><i class="icon icon-home"></i> <span>Dashboard控制面板</span></a> </li>
    <li> <a href="<%=request.getContextPath()%>/study?method=page"><i class="icon icon-signal"></i> <span>Study news留学信息</span></a> </li>
    <li> <a href="<%=request.getContextPath()%>/travel?method=page"><i class="icon icon-inbox"></i> <span>Travel New活动信息</span></a> </li>
    <li><a href="<%=request.getContextPath()%>/news?method=page"><i class="icon icon-th"></i> <span>Recent News近期新闻</span></a></li>
    <li class="active"><a href="<%=request.getContextPath()%>/member?method=page"><i class="icon icon-fullscreen"></i> <span>Members centre会员中心</span></a></li>
    <c:choose>
     <c:when test="${sessionScope.assist.type eq 0}">
      <li><a href="<%=request.getContextPath() %>/assist"><i class="icon icon-th-list"></i> <span>助理管理</span></a></li>
     </c:when>
    </c:choose>
      <li><a href="<%=request.getContextPath() %>/task"><i class="icon icon-th-list"></i> <span>任务管理</span></a></li>
  </ul>
</div>

<div id="content"   class="easyui-layout" >
        <div class="easyui-panel" style="padding:5px;" >
		<a href="#" class="easyui-linkbutton" style="position:relative;left:50px" data-options="plain:true">Follower:<span style="background:red;color:white;padding:5px;border-radius:10px;font-size:16px;">0</span></a>
		<a href="#" onclick="ordinary()" class="easyui-linkbutton" style="position:relative;left:200px;" data-options="plain:true">Probation members:<span style="background:red;color:white;padding:5px;border-radius:10px;font-size:16px;">0</span></a>
		<a href="#" onclick="vip()" class="easyui-linkbutton" style="position:relative;left:400px;" data-options="plain:true">Members:<span style="background:red;color:white;padding:5px;border-radius:10px;font-size:16px;">0</span></a>
		<a href="#" onclick="total()" class="easyui-linkbutton" style="position:relative;left:600px;" data-options="plain:true">total:<span style="background:red;color:white;padding:5px;border-radius:10px;font-size:16px;">0</span></a>
        </div>
        <div>
		<div region="center" 
			style="padding: 0px; background: #eee;">
			<table id="dg"  toolbar="#toolbar"></table>
			<div id="toolbar">
			<a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true"
					onclick="addUser()">添加会员 </a> 
			 <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true"
					onclick="sendEmail()">发送邮件</a> 
					 <a href="#"
					class="easyui-linkbutton" iconCls="icon-large-smartart" plain="true"
					onclick="myUsers()">我负责的会员</a>
			</div>
			<!-- dialog弹出框 -->
			
			<div id="dlg1" class="easyui-dialog"
				style="width:600px; height: 600px; padding: 10px 20px"
				closed="true" buttons="#dlg-buttons1">
				<div class="ftitle" style="text-align: center;">添加会员</div>
				<form id="fm1" method="post" novalidate>

					<div class="fitem">
						<label>姓名:</label> <input name="name" id="name0"  required='true' class="easyui-textbox"
							  style="width:250px"  >
					</div>
					<div class="fitem">
						<label>会员类型:</label> 
						  <select name="type"  id="type0" required='true' class="easyui-combobox" style="width:250px" >
						   <option value='0'></option>
						   <option value='1'>普通会员</option>
						   <option value='2'>vip会员</option>
						  </select>
					</div>
					<div class="fitem">
						<label>联系电话:</label> <input name="phone"  id="phone0" class="easyui-textbox"
							  style="width:250px"  >
					</div>
					<div class="fitem">
						<label>电子邮箱:</label> <input name="email"  id="email0" class="easyui-textbox"
							  style="width:250px"  >
					</div>
					<div class="fitem">
						<label>在读学校:</label> <input name="school" id="school0" class="easyui-textbox"
							 style="width:250px"  >
					</div>
					<div class="fitem">
						<label>在读年级:</label> 
						<select name="grade" id="grade0" class="easyui-combobox" style="width:250px" >
						  <option value='0'></option>
						   <option value='1'>大一</option>
						   <option value='2'>大二</option>
						   <option value='3'>大三</option>
						   <option value='4'>大四</option>
						  </select>
					</div>
					<div class="fitem">
						<label>截止日期:</label> <input  id="due0" style="width:250px" name="due" class="easyui-datebox">
					</div>
					<div class="fitem">
						<label>个人助理:</label> 
						<select class="easyui-combogrid"  id="assistid0" name="assistid" id="responsibility" style="width:250px" data-options="
								panelWidth: 500,
								idField: 'id',
								textField: 'name',
								url: '<%=request.getContextPath() %>/assist?method=list',
								method: 'get',
								pagination : true,
								columns: [[
									{field:'id',title:'编号',width:80},
									{field:'name',title:'姓名',width:120},
									{field:'department',title:'部门',width:80,align:'right'},
									{field:'phone',title:'电话',width:80,align:'right'}
								]],
								fitColumns: true
							">
						</select>
					</div>
				</form>
			</div>
			<div id="dlg-buttons1">
				<a href="javascript:void(0)" class="easyui-linkbutton c6"
					iconCls="icon-ok" onclick="doAdd()" style="width:90px">Save</a> <a
					href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-cancel"
					onclick="javascript:$('#dlg1').dialog('close')" style="width:90px">Cancel</a>
			</div>
			  <div id="dlg4" class="easyui-dialog"
				left='220px' top='77px' width='1129px' height='774px' style="background:#eee;"
				closed="true" buttons="#dlg-buttons4">
				 <a href="#" class="easyui-linkbutton" iconCls="icon-large-smartart"
					plain="true" id="file-btn">附件</a>
 				 <a href="#" class="easyui-linkbutton" iconCls="icon-large-smartart"
					plain="true" id="task-btn">任务</a>
 				 <a href="#" class="easyui-linkbutton" iconCls="icon-large-smartart"
					plain="true" onclick="userLink()">链接 </a>
 				  <a href="#" class="easyui-linkbutton" iconCls="icon-large-smartart" plain="true"
					onclick="userTravels()">活动</a>
			<hr/>
				<table class="table table-bordered table-invoice">
				<caption>会员资料	<span class="easyui-linkbutton" id="edit-btn">编辑</span>
				</caption>
                  <tbody>
                    <tr>
                    <tr>
                      <td><strong> 用户id:</strong></td>
                      <td id='uid'></td>
                    </tr>
                    <tr>
                      <td><strong>姓名</strong></td>
                      <td id="name"></td>
                    </tr>
                    <tr>
                      <td><strong>会员类型</strong></td>
                      <td id="type"></td>
                    </tr>
                    <tr>
                    <td ><strong>联系电话</strong></td>
                    <td id='phone'></td>
                    </tr>
                    <tr>
                     <td><strong>电子邮箱</strong></td>
                     <td id='email'></td>
                    </tr>
                    <tr>
                     <td><strong>在读学校</strong></td>
                     <td id="school"></td>
                    </tr>
                    <tr>
                     <td><strong>在读年级</strong></td>
                     <td id='grade'></td>
                    </tr>
                    <tr>
                     <td><strong>会员有效期至</strong></td>
                     <td id='due'></td>
                    </tr>
                    <tr>
                     <td><strong>个人助理</strong></td>
                     <td id='assistid'></td>
                    </tr>
                    </tbody>
                </table><hr/>
	        <div style="width:95%;min-height:60px;margin:20px auto;">
			 <textarea placeholder="add a comment....." title='可在此添加留言' id="commentid" style="overflow:hidden;height:auto;width:100%;background:white" ></textarea>
			 <div>
			 <div  class="easyui-linkbutton" iconCls="icon-add" plain='true' id="addcomment">添加备注</div><hr/>
			  <div id="commentlist"></div>
			 </div>
			</div>
			</div>
			<!-- <div id="dlg-buttons4">
			 <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="doSend()" style="width:90px">Save</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg4').dialog('close')" style="width:90px">Cancel</a>
			</div> -->
			<div id="dlg5" class="easyui-dialog"
				style="width:600px; height: 500px; padding: 10px 20px"
				closed="true" buttons="#dlg-buttons5">
				<div class="ftitle" style="text-align: center;">发送邮件</div>
				<form id="fm5" method="post" novalidate>
					<div class="fitem">
						<label>收件人:</label> <input name="to" id="to" class="easyui-textbox" 
						required="true"  style="width:300px" >
					</div>
					<div class="fitem">
					<label>邮件主题:</label> <input name="subject" class="easyui-textbox"
						required="true"  style="width:300px">
					</div>
					<div class="fitem">
						<label>邮件正文:</label>
					   <textarea style="float:left;"  class="easyui-kindeditor " id="editor_id" name="content"   required="true"></textarea>
					</div>
				</form>
			</div>
			<div id="dlg-buttons5">
			 <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="send()" style="width:90px">发送</a>
			<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg5').dialog('close')" style="width:90px">Cancel</a>
			</div>
			
			</div><div id="dlg7" class="easyui-dialog"
				style="width:600px; height: 500px; padding: 10px 20px"
				closed="true" buttons="#dlg-buttons7">
				<span iconCls="icon-add"  id="insertfile" class="easyui-linkbutton" >上传</span>
				<div class="ftitle" style="text-align: center;">客户文件</div>
		        <table id='file-tab' style="border:1px dotted gray" class="table"></table>
			</div>
			</div>
			<div id="dlg8" class="easyui-dialog"
				style="width:600px; height: 500px; padding: 10px 20px"
				closed="true" buttons="#dlg-buttons8">
				<div class="ftitle" style="text-align: center;">相关任务</div>
		        <table id='task-tab' style="border:1px dotted gray" class="table"></table>
			</div>
			<div id="dlg9" class="easyui-dialog"
				style="width:600px; height: 500px; padding: 10px 20px"
				closed="true" buttons="#dlg-buttons9">
				<div class="ftitle" style="text-align: center;">链接</div>
                <div style="width:95%;min-height:60px;margin:20px auto;">
			     <textarea placeholder="edit url....." id="user-link" title="可点击修改"  style="overflow:hidden;height:auto;width:100%;background:white" ></textarea>
			    </div><hr/>
			    会员相关链接
			    <a  href="#" style="margin:0px auto" id="link-id"  ></a>			
			</div>
			<div id="dlg10" class="easyui-dialog"
				style="width:600px; height: 500px; padding: 10px 20px"
				closed="true" buttons="#dlg-buttons10">
				<div class="ftitle" style="text-align: center;">参与的活动</div>
		        <table id='travel-tab' style="border:1px dotted gray" class="table"></table>
			</div>
			<div id="dlg11" class="easyui-dialog"
				style="width:900px; height: 600px; padding: 10px 20px"
				closed="true" buttons="#dlg-buttons11">
				 <h3 id="tit" style="text-align:center;"></h3>
				 <div>发布时间:<span id="span1" style="padding:0px 500px 0px 10px;"></span>收费方式：<span id='span2'></span>元</div>
				<hr/>
				<div id="travel"></div>
			</div>
			
			<div id="dlg12" class="easyui-dialog"
				style="width:600px; height: 600px; padding: 10px 20px"
				closed="true" buttons="#dlg-buttons12">
				<div class="ftitle" style="text-align: center;">编辑会员资料</div>
				<form id="fm12" method="post" novalidate>
					<div class="fitem">
						<label>会员id:</label> <input name="uid" id="uid2" class="easyui-textbox"
							editable='false' style="width:250px"  >
					</div>
					<div class="fitem">
						<label>姓名:</label> <input name="name" id="name2"  class="easyui-textbox"
							  style="width:250px"  >
					</div>
					<div class="fitem">
						<label>会员类型:</label> 
						  <select name="type"  id="leixing" class="easyui-combobox" style="width:250px" >
						   <option value='1'>普通会员</option>
						   <option value='2'>vip会员</option>
						  </select>
					</div>
					<div class="fitem">
						<label>联系电话:</label> <input name="phone"  id="phone2" class="easyui-textbox"
							  style="width:250px"  >
					</div>
					<div class="fitem">
						<label>电子邮箱:</label> <input name="email"  id="email2" class="easyui-textbox"
							  style="width:250px"  >
					</div>
					<div class="fitem">
						<label>在读学校:</label> <input name="school" id="school2" class="easyui-textbox"
							 style="width:250px"  >
					</div>
					<div class="fitem">
						<label>在读年级:</label> 
						<select name="grade" id="grade2" class="easyui-combobox" style="width:250px" >
						   <option value='1'>大一</option>
						   <option value='2'>大二</option>
						   <option value='3'>大三</option>
						   <option value='4'>大四</option>
						  </select>
					</div>
					<div class="fitem">
						<label>截止日期:</label> <input  id="due2" style="width:250px" name="due" class="easyui-datebox">
					</div>
					<div class="fitem">
						<label>个人助理:</label> 
						<select class="easyui-combogrid"  id="assistid2" name="assistid" id="responsibility" style="width:250px" data-options="
								panelWidth: 500,
								idField: 'id',
								textField: 'name',
								url: '<%=request.getContextPath() %>/assist?method=list',
								method: 'get',
								pagination : true,
								columns: [[
									{field:'id',title:'编号',width:80},
									{field:'name',title:'姓名',width:120},
									{field:'department',title:'部门',width:80,align:'right'},
									{field:'phone',title:'电话',width:80,align:'right'}
								]],
								fitColumns: true
							">
						</select>
					</div>
				</form>
			</div>
			<div id="dlg-buttons12">
				<a href="javascript:void(0)" class="easyui-linkbutton c6"
					iconCls="icon-ok" onclick="doedit()" style="width:90px">Save</a> <a
					href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-cancel"
					onclick="javascript:$('#dlg12').dialog('close')" style="width:90px">Cancel</a>
			</div>
		    <div id="dlg13" class="easyui-dialog"
				style="width:300px; height: 200px; padding: 10px 20px"
				closed="true" buttons="#dlg-buttons13">
				<input class="easyui-datetimebox"  id="timer"]>
				
			</div>
			<div id="dlg-buttons13">
				<a href="javascript:void(0)" class="easyui-linkbutton c6"
					iconCls="icon-ok" onclick="setTimer()" style="width:90px">Save</a> <a
					href="javascript:void(0)" class="easyui-linkbutton"
					iconCls="icon-cancel"
					onclick="javascript:$('#dlg13').dialog('close')" style="width:90px">Cancel</a>
			</div>
	</div>
</div>
</div>
<!--Footer-part-->
<div class="row-fluid">
  <div id="footer" class="span12"> 2016 &copy; <a href="http://themedesigner.in/">guangzhoushuntian information technology</a> </div>
</div>
<!--end-Footer-part--> 

</body>
</html>
